import { comsType } from "../../../../constants/form";

const { 
  FORM_FOOTER, FORM_HEADER,
  COMBOBOX, SELECT, ATTACHMENT, PICTURE
} = comsType;

const _type = (comTypes, not = false) => {
  return com => {
    const isexist = ~comTypes.indexOf(com.type);

    if (not) return !isexist;

    return isexist;
  }
};

export const isNormal = _type([FORM_FOOTER, FORM_HEADER], true);
export const isOptional = _type([COMBOBOX, SELECT]);
export const isAttachment = _type([ATTACHMENT]);
export const isPicture = _type([PICTURE]);
export const isVisible = com => com.visible;
export const needValid = com => !com.config.complex && isVisible(com);